#pragma once

#include <iostream>
#include <assert.h>


namespace qh
{
	class string
	{
		using irerator = char*;
		using const_iterator = const char*;
	public:
		string(const char* str = " ")
			:_str(new char[_size + 1]{'\0'})
			,_capacity(_size)
		{
			_size = strlen(str);
		}

		~string()
		{
			delete[] _str;
			_size = 0;
			_capacity = 0;
		}

		string& operator=(const char* str);

		char* c_str() {return _str;}

		//Element access
		char& operator[](size_t i) { return _str[i]; }
		const char& operator[](size_t i) const { return _str[i]; }
		char front() { return _str[0]; }
		char back() { return _str[_size - 1]; }

		//Iterator
		size_t begin() const { return 0; }
		size_t end() const { return _size; }


		//Capacity
		size_t size() const { return _size; }
		size_t capacity() const { return _capacity; }
		void reserve(size_t n = 0);
		void clear() {  }


		//Modifiers
		string& operator+=(const string& str);
		string& operator+=(const char* str);

		void insert(size_t pos, const char* str);

		void push_back(char ch);

	private:
		char* _str;
		size_t _size;
		size_t _capacity;
	};
}
